<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
class Supplys extends Model
{
	//指定表名
	protected $table='supply';
	//指定id
	protected $primaryKey ='id';
	//自动维护时间戳
	public $timestamps= true;
	public function tags()
	{
		return $this->belongsToMany('App\Tags', 'supply_tag', 'supply_id', 'tag_id');
	}
	public function  sales(){
		return $this->hasMany('App\Sales','supply_id');
	}
	public function  photos(){
		return $this->hasMany('App\Photo','supply_id');
	}
	
	public function getBean(){
		return $this->hasOne('App\Beans','id','bean');
	}
	public function getContinent(){
		return $this->hasOne('App\Dicts','id','continent');
	}
	public function getCountry(){
		return $this->hasOne('App\Tags','id','country');
	}
	public function getSpecies(){
		return $this->hasOne('App\Tags','id','species');
	}
	public function getMethod(){
		return $this->hasOne('App\Tags','id','method');
	}
	public function getRoast(){
		return $this->hasOne('App\Tags','id','roast');
	}
	public function showcafe(){
		return $this->hasOne('App\Cafe','id','cafe');
	}
	public function getAssistTag(){
		return $this->hasOne('App\Tags','id','assist_tag');
	}
	public function cafes()
	{
		return $this->belongsToMany('App\Cafe', 'cafe_supply', 'supply_id', 'cafe_id');
	}
}
